package oa.hleast.xswl.service.pms;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import oa.hleast.xswl.mapper.pms.SpuReviewLogMapper;
import oa.hleast.xswl.pojo.domain.SysUser;
import oa.hleast.xswl.pojo.domain.pms.SpuReviewLog;
import oa.hleast.xswl.service.ISysUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: 302
 * @date: 2021-10-18 18:31:46
 * @description: 商品审核记录表(SpuReviewLog)接口实现
 */
@AllArgsConstructor
@Slf4j
@Transactional
@Service("spuReviewLogService")
public class SpuReviewLogServiceImpl extends ServiceImpl<SpuReviewLogMapper, SpuReviewLog> implements SpuReviewLogService {

    private final ISysUserService sysUserService;

    @Override
    public boolean saveLog(Long userId, Integer code, Long spuId, Long storeId, String remark) {

        SysUser sysUser = sysUserService.getById(userId);

        SpuReviewLog spuReviewLog = SpuReviewLog.builder()
                .reviewStatus(code)
                .spuId(spuId)
                .storeId(storeId)
                .operationUserId(userId)
                .operationUserName(sysUser.getUsername())
                .reviewRemark(remark)
                .build();

        boolean save = this.save(spuReviewLog);

        return save;
    }
}
